<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>取车站点</title>
	<link rel="stylesheet" href="<%=path %>/css/amazeui.min.css" />
	<link rel="stylesheet" href="<%=path %>/css/wgj_style.css" />
	<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
	<script type="text/javascript" src="<%=path %>/js/amazeui.min.js"></script>
	<script src="https://static.alipay.com/aliBridge/1.0.0/aliBridge.min.js"></script>
<!--获取城市列表功能8.1以上钱包支持-->
	<script type="text/javascript">
		$(function(){
			if($("#cityName").val()==""){
				if(navigator.userAgent.indexOf("AlipayClient")===-1){
			    	alert('请在支付宝钱包内运行');
				}else{
				    if((Ali.alipayVersion).slice(0,3)>=8.1){
				        Ali.getCities({
				            currentCity: '杭州市',
				            adcode:'310100'
				        }, function(result) {
				            //成功获取城市的情况
				            $("#cityName").val(result.city);
				            var url="<%=path%>/dept/queryDeptJson"
				            var data={"cityName":result.city};
				            $.post(url,data,function(data){
				            	if(data.deptList!=null){
				            		var html="";
				            		for(var i = 0; i < data.deptList.length; i++){
				            			html+="<div class=\"am-panel\"><div class=\"am-panel-hd\"><h4 class=\"am-panel-title\" data-am-collapse=\"{parent: '#accordion', target: '#do-not-say-${status.count }'}\" onclick=\"selectDept('"+data.deptList[i].TNAME+"','do-not-say-"+i+"');\">"+data.deptList[i].TNAME+"</h4>";
	           							html+="<div id=\"do-not-say-"+i+"\" class=\"am-panel-collapse am-collapse\"></div></div></div>";
				            		}
				            	}else{
				            		html="该城市站点正在开通中,敬请期待";
				            	}
				            	$("#accordion").append(html);
				            })
				        });
				    }else{
				        Ali.alert({
				            title: '亲',
				            message: "请升级您的钱包到最新版",
				            button: "确定"
				        });
				    }
				}
				}
			})
		
	</script>
	<script type="text/javascript">
		//选择城市页面
		function changeCity(){
			window.location.href="<%=path%>/carType/queryAllCity?cityName="+$("#cityName").val();
		}
		
		//查询场站
		function selectDept(deptName,id){
			$("#"+id).html("");;
			var url="<%=path%>/dept/queryDeptBytname";
			var data={"dept.tname":deptName};
			$.post(url,data,function(data){
				if(data.deptList!=null){
					var html="<ul class='am-panel-bd'>"
					for ( var i = 0; i < data.deptList.length; i++) {
						html+="<li><a href=\"javascript:void(0);\" onclick=\"backIndex("+data.deptList[i].DEPTID+",'"+data.deptList[i].DEPTNAME+"');\">"+data.deptList[i].DEPTNAME+"</a><li>";
					}
					html+="</ul>";
					$("#"+id).append(html);
				}
			});
		}
		
		function backIndex(id,deptName){
			var url="<%=path%>/dept/backInex?id="+id+"&deptName="+deptName;
			window.location.href=url;
			
		}
	</script>
</head>
<body>
<section>
	<div class="quche mt30" style="border-bottom:1px solid #dedede;" >
    	<div class="am-input-group am-input-group-lg">
          	<span class="am-input-group-label arrow_bg">当前定位城市</span>
          	<input type="text" class="am-form-field close_bg" value="${cityName }" id="cityName" onclick="changeCity();">
        </div>
    </div>
    <div class="am-panel-group" id="accordion">
	    <c:forEach items="${deptList }" var="dept" varStatus="status">
	    	<div class="am-panel">
	            <div class="am-panel-hd">
	              	<h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#do-not-say-${status.count }'}" onclick="selectDept('${dept.tname}','do-not-say-${status.count }');">${dept.tname }</h4>
	            </div>
	            <div id="do-not-say-${status.count }" class="am-panel-collapse am-collapse">
	            </div>
	      	</div>
	    </c:forEach>
    </div>
</section>
</body>
</html>

